package com.wms.controller;

import com.wms.dto.WarehouseOperationsReqDto;
import com.wms.pojo.PageResult;
import com.wms.pojo.Result;
import com.wms.service.WarehouseOperationsService;
import com.wms.vo.WarehouseOperationsResVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author Yzxxn
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/warehouseOperations")
public class WarehouseOperationsController {

    private final WarehouseOperationsService warehouseOperationsService;

    /*
     * 分页查询
     * */
    @GetMapping("/page")
    public Result getOperationsByPage(String jobCode, Integer status, Integer pageNum, Integer pageSize) {
        PageResult result = warehouseOperationsService.getOperationsByPage(jobCode, status, pageNum, pageSize);
        return Result.success(result);
    }


    /*
     * 新增作业
     * */
    @PostMapping
    public Result addOperation(@RequestBody WarehouseOperationsReqDto dto) {
        warehouseOperationsService.addOperation(dto);
        return Result.success();
    }

    /*
     * 查看详情
     * */
    @GetMapping("/detail/{id}")
    public Result queryDetailOperationById(@PathVariable Long id) {
        WarehouseOperationsResVo vo = warehouseOperationsService.queryDetails(id);
        return Result.success(vo);
    }

    /*
     * 作业确认
     * */
    @PutMapping("/confirm/{id}")
    public Result confirm(@PathVariable Long id) {
        warehouseOperationsService.confirm(id);
        return Result.success();
    }

    /*
     * 调整
     * */
    @PutMapping("/adjust/{id}")
    public Result adjust(@PathVariable Long id) {
        warehouseOperationsService.adjust(id);
        return Result.success();
    }

    /*
     * 删除
     * */
    @DeleteMapping
    public Result deleteOperation(Long id) {
        warehouseOperationsService.deleteOperation(id);
        return Result.success();
    }
}
